import { _decorator, Component, find, input, Input, EventKeyboard, KeyCode, SpriteFrame, director, sys, } from 'cc';

const { ccclass, property } = _decorator;

@ccclass('SSS_InputManager')
export default class SSS_InputManager extends Component {
        static Instance: SSS_InputManager;

        onLoad() {
                SSS_InputManager.Instance = this;

                input.on(Input.EventType.KEY_DOWN, this.onKeyDown, this);
        }

        async onKeyDown(event: EventKeyboard) {
                if (event.keyCode == KeyCode.ARROW_UP || event.keyCode == KeyCode.KEY_W) {
                        // console.log(`up`);
                        // SS_GameManager.Instance.上一关();
                }
                if (event.keyCode == KeyCode.ARROW_DOWN || event.keyCode == KeyCode.KEY_S) {
                        // console.log(`down`);
                        // SS_GameManager.Instance.下一关();
                }
                if (event.keyCode == KeyCode.ARROW_LEFT || event.keyCode == KeyCode.KEY_A) {
                        // console.log(`left`);
                        // SS_GameManager.Instance.上一关();
                        // YangLeGeYang_GameManager.Instance?.上一关();
                        // ChengYu_Main.Instance?.上一关();

                        // JiuJiuXiaoDongWu_GameManager.Instance?.上一关();
                        // LianLianKan.Instance?.上一关();

                        // DaoShuiPaiXu_GameManager.Instance?.上一关();

                        // LianLianKan_GameData.CurrentLevelIndex--;
                        // let currentSceneName = director.getScene().name;
                        // director.loadScene(`LianLianKan_Game_Scene`);
                }
                if (event.keyCode == KeyCode.ARROW_RIGHT || event.keyCode == KeyCode.KEY_D) {
                        console.log(`right`);
                        // SS_GameManager.Instance.下一关();

                        // YangLeGeYang_GameManager.Instance?.下一关();
                        // ChengYu_Main.Instance?.下一关();

                        // JiuJiuXiaoDongWu_GameManager.Instance?.下一关();
                        // LianLianKan.Instance?.下一关();

                        // DaoShuiPaiXu_GameManager.Instance?.下一关();
                }

                if (event.keyCode == KeyCode.SPACE) {
                        console.log(`空格`);

                        sys.localStorage.clear();
                }

                if (event.keyCode == KeyCode.ESCAPE) {
                }
                if (event.keyCode == KeyCode.NUM_1) {
                        console.log("num1");

                }
                if (event.keyCode == KeyCode.NUM_2) {
                        console.log("num2");
                        
                }
                if (event.keyCode == KeyCode.NUM_3) {
                      
                }
                if (event.keyCode == KeyCode.NUM_4) {
                      
                }
        }
}